package com.mwf.domain.tag.service;

import com.mwf.domain.tag.adapter.repository.ITagRepository;
import com.mwf.domain.tag.model.entity.CrowdTagsJobEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class TagService implements ITagService {

    @Resource
    private ITagRepository tagRepository;


    @Override
    public void execTagBatchJob(String tagId, String batchId) {
        CrowdTagsJobEntity crowdTagsJobEntity = tagRepository.queryCrowdTagsJobEntity(tagId, batchId);

        //采集数据
        ArrayList<String> arrayList = new ArrayList<String>() {
            {
                add("xiaofuge");
                add("liergou");
            }
        };

        //插入标签库
        arrayList.forEach(item -> {
            tagRepository.addCrowdTagsUserId(tagId,item);
        });

        //更新标签统计量
        tagRepository.updateCrowdTagsStatistics(tagId,arrayList.size());
    }
}
